export default function getTreeData(
  data: any[],
  id: string, //id
  pid: string, // pid
  children: string,
  rootPid: null | string
) {
  const cloneData = JSON.parse(JSON.stringify(data))
  return cloneData.filter((father: any) => {
    const childrenArr = cloneData.filter((child: unknown) => father[id] === (child as any)[pid])
    father[children] = childrenArr.length > 0 ? childrenArr : []
    return father[pid] === rootPid
  })
}
export function test() {}
